package com.cartagena.financo.util;

import java.math.BigDecimal;

import com.cartagena.financo.model.Category;
import com.cartagena.financo.model.TransactionType;

public class CategorySum {

    private Category category;
    private BigDecimal total;
    private TransactionType type;

    public CategorySum(Category category) {
        super();
        this.category = category;
        this.total = new BigDecimal(0);
    }

    public void addValue(BigDecimal value) {
        total = total.add(value);
    }

    public void setType() {
        type = total.signum() == -1 ? TransactionType.DEBIT : TransactionType.CREDIT;
    }

    public void abs() {
        total = total.abs();        
    }

    public Category getCategory() {
        return category;
    }

    public BigDecimal getTotal() {
        return total;
    }

    public TransactionType getType() {
        return type;
    }
}
